package top.hkyzf.study.leetcode.bit;

import org.junit.Test;

/**
 * @author 朱峰
 * @date 2022-2-1 21:11
 */
public class 颠倒二进制位_190 {
    public int reverseBits(int n) {
        int result = 0;
        for (int i = 0; i < 32; i++) {
            result = (result << 1) | (n & 1);
            n = n >> 1;
        }
        return result;
    }

    @Test
    public void testReverseBits () {
        int n = 0b11111111111111111111111111111101;
        System.out.println(reverseBits(n));
    }
}
